local skill = fk.CreateSkill {
  name = "lvshi__benyu",
}
Fk:loadTranslationTable{
  ["lvshi__benyu"] = "贲育",
  [":lvshi__benyu"] = "当你受到伤害后，你可弃置所有角色共计两张牌，你每以此法弃置一张【桃】或【酒】后，你摸三张牌。",
  ["#lvshi__benyu-choose"] = "贲育：你可以依次选择角色，弃置其手牌或装备区内的牌（共计至多%arg张，还剩%arg2张）",

  ["$lvshi__benyu1"] = "过则不可不攻，攻之则必克。",
  ["$lvshi__benyu2"] = "不去眉睫之祸，而慕贵育之死。",
}

skill:addEffect(fk.Damaged, {
  anim_type = "masochism",
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local to = room:askToChoosePlayers(player, {
      min_num = 1,
      max_num = 1,
      targets = table.filter(player.room:getAlivePlayers(false), function (p) return not p:isNude() end),
      skill_name = skill.name,
      prompt = "#lvshi__benyu-choose:::"..tostring(2)..":"..tostring(2),
      cancelable = true,
    })
    if #to > 0 then
      event:setCostData(self, {tos = to})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local n = 2
    local to = event:getCostData(self).tos[1]
    repeat
      local cards = room:askToChooseCards(player, {
        target = to,
        min = 1,
        max = n,
        flag = "he",
        skill_name = skill.name,
      })
      if #cards > 0 then
        room:throwCard(cards, skill.name, to, player)
        for _, id in ipairs(cards) do
          local card = Fk:getCardById(id)
          if card.trueName == "peach" or card.trueName == "analeptic" then
            player:drawCards(3, skill.name)
          end
        end
        n = n - #cards
        if n <= 0 then break end
      end
      local targets = table.filter(room:getAlivePlayers(false), function (p) return not p:isNude() end)
      if #targets == 0 then break end
      local tos = room:askToChoosePlayers(player, {
        min_num = 1,
        max_num = 1,
        targets = targets,
        skill_name = skill.name,
        prompt = "#lvshi__benyu-choose:::"..tostring(2)..":"..tostring(n),
        cancelable = true,
      })
      if #tos > 0 then
        to = tos[1]
      else
        break
      end
    until player.dead
  end,
})


return skill